home *** CD-ROM | disk | FTP | other *** search
-
-
- ez.lib Version 1.3 by Joe Siebenmann
-
-
-
- *** See the Disclaimer in EZAsm.doc ***
-
-
- ------ NO LIABILITY FOR CONSEQUENTIAL DAMAGES ------
-
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DAMAGES
- WHATSOEVER ARISING OUT OF THE USE OF OR INABILITY TO USE
- THESE PROGRAMS.
-
-
-
-
-
-
- --- New for Version 1.3 ---
-
-
- o New functions:
-
- stricmp()
- gets()
-
-
- o sprint() now returns number of characters processed in D0.
-
- o KPrint(), Print() and AtoI() are now kprint(), print(), and atoi().
-
-
-
-
-
- Ez.lib is a scanned library consisting of object files which are
- individually loaded if there is an external reference to one of them.
- Many "c.lib" like functions are included which are not normally available
- with assembly language. With these functions, EZAsm can be used
- for a much wider range of programming applications.
-
-
-
- *********************
- * Print Functions *
- *********************
-
-
- Usage: print( FormatString DataStream [...] )
-
- kprint( FormatString DataStream [...] )
-
-
-
- Performs C-like formatting of the data stream.
- Where % formatting commands are found in the FormatString, they're
- replaced with the corresponding element(s) in the DataStream.
- print() outputs the results to the current output handle.
-
- kprint() is like Kprintf() in that it sends its output
- out the serial port at 9600 baud, where if you have another computer
- running a terminal program, and hooked up with a null modem cable,
- all the output can be captured and reviewed, even if your program is
- taking over the machine, or crashes! This is a fantastic debugging tool!
-
- More information on RawDoFmt() ( ExecBase ), which these use, can
- be found in the AutoDocs.
-
-
- FormatString
-
- A C-like null terminated format string.
- The following % options are supported:
-
- %[flags][width.limit][length]type
-
-
- flags - '-' specifies left justification.
- width - field width. If fist character is a '0', field is
- padded with leading zeros.
- limit - maximum number of characters output from a string ( %s only )
- length - data size: 'l' for LONG ( WORD is the default size )
- ( BYTE data MUST be moved to a WORD or LONG for display )
-
- type - types supported:
-
- d - decimal
- x - hexadecimal
- s - string
- c - character
-
-
- DataStream
-
- Accepts MULTIPLE variable names, registers, constants etc..
-
- Constant data ( 2, $f4, 'a', etc. ) is pushed as LONG, so use 'l'.
- ( %ld %lx %lc )
-
-
- Examples:
-
- print( "word %ld = %s\n" 1 "YHWH" )
-
- kprint( "foo = %08lx D2 = %08lx\n" foo d2 )
-
-
-
- In print() statements without a DataStream argument, you
- can drop the extra "*" argument and use it like this:
-
- print( "Hello, World!\n" )
-
-
-
- o A 200 byte buffer for k/print() is allocated on the stack frame
- ( at .pbuf ) so no AllocMem() is needed. Be careful when using "%s"
- and printing large strings, as this could overflow the buffer and
- trash your variables/program.
-
- o print() needs the current output handle, and _DOSBase,
- and will get these automatically. "OutHandle" will contain
- the current output handle.
-
-
- o EZAsm supports argument strings surrounded by double quotes.
- Strings are automatically NULL terminated.
- The following C character constants are supported:
-
- \b backspace
- \f form feed
- \n newline
- \r carriage return
- \t horizontal tab
- \v vertical tab
- \\ backslash
- \" double quote
- \' single quote
- \nnn octal character value
- \xnn hex character value
-
-
- Examples:
-
- "Hello, World!\n"
-
- "\x1b[32mEZAsm 1.8\x1b[39m\n"
-
-
-
-
- *************************
- * Character Functions *
- *************************
-
-
- Usage: [!] is.....( StringPointer ) {
- .
- .
- }
-
-
- [!] is.....( StringPointer ) {
- .
- .
- } else {
- .
- .
- }
-
-
- [!] is.....( StringPointer ) label
-
-
-
- Looks at the character at StringPointer address and,
- if the test is satisfied, based on the Z flag,
- performs the TRUE action.
-
-
- These C-like functions are supported:
-
-
- isalnum() alphabetic or digit character?
- isalpha() alphabetic character?
- isascii() ASCII character? ( $0-$7f )
- iscntrl() control character? ( $0-$1f or $7f )
- isdigit() digit character?
- isgraph() graphics character? ( $21-$7e )
- islower() lowercase letter?
- isprint() printable character? ( including space )
- ispunct() punctuation character?
- isspace() white space character? ( $20 $09-$0c )
- isupper() uppercase letter?
- isxdigit() hexadecimal digit character?
-
-
-
-
- ********************
- * String Compare *
- ********************
-
-
- Usage: [D0 =] strcmp( String1 String2 )
-
- [D0 =] strncmp( String1 String2 Length )
-
- [D0 =] stricmp( String1 String2 )
-
-
-
- [!] str...( String1 String2 ) {
- .
- .
- }
-
-
- [!] str...( String1 String2 ) {
- .
- .
- } else {
- .
- .
- }
-
-
- [!] str...( String1 String2 ) label
-
-
-
- Compares strings String1 and String2 ( for strncmp(), at most,
- Length characters are compared ) The return value is -1 if String1
- was less, 1 if String1 was greater, and 0 if String1 and String2
- match exactly.
-
- stricmp() is a case insensitive string compare ( "Cat" = "cat" )
- returning 0 for equal, <0 if String1 was less, and >0 if String1
- was greater.
-
- As with the C versions, you'll need to use "!" to "flip" the
- zero result when testing for strings being equal. To test for
- not equal, omit the "!".
-
-
-
- *********************
- * Data Conversion *
- *********************
-
-
-
- Usage: D0 = atoi( StrAddr FormatString )
-
-
-
- Converts ASCII digit characters found at StrAddr, according to
- the format specified by FormatString, and places the result in D0.
- Conversion is stopped when a non-valid digit character is found.
-
- StrAddr
- Address of first ASCII digit character.
-
- FormatString
-
- "%d" convert (signed) decimal number
- "%x" convert hexadecimal number
-
- ----------------------------------------------
-
- Usage: [D0 =] sprint( Buffer FormatString DataStream [...] )
-
-
-
- Performs C-like formatting of the data stream.
- Where % formatting commands are found in the FormatString, they're
- replaced with the corresponding element(s) in the DataStream.
- The result is placed in Buffer. The number of characters placed into
- Buffer is returned in D0, excluding the terminating NULL.
-
- More information on RawDoFmt() ( ExecBase ), which this uses, can
- be found in the AutoDocs.
-
-
- FormatString
-
- A C-like null terminated format string.
- The following % options are supported:
-
- %[flags][width.limit][length]type
-
-
- flags - '-' specifies left justification.
- width - field width. If fist character is a '0', field is
- padded with leading zeros.
- limit - maximum number of characters output from a string ( %s only )
- length - data size: 'l' for LONG ( WORD is the default size )
- ( BYTE data MUST be moved to a WORD or LONG for display )
-
- type - types supported:
-
- d - decimal
- x - hexadecimal
- s - string
- c - character
-
-
- DataStream
-
- Accepts MULTIPLE variable names, registers, constants etc..
-
- Constant data ( 2, $f4, 'a', etc. ) is pushed as LONG, so use 'l'.
- ( %ld %lx %lc )
-
-
-
-
-
-
- Example:
-
- sprint( Buf "\t\tmove%s\t#%ld,d1\n" ".l" 0 )
-
- ( see Mk.s for more examples )
-
-
-
- **********************
- * String Functions *
- **********************
-
-
-
-
- Usage: [location =] search( StrAddr String )
-
-
- Searches for the first occurance of String starting at
- StrAddr. If a match is found, the address of the first
- matching byte from StrAddr is returned in D0, otherwise D0 = 0.
-
- ( Use this function when searching for two or more characters
- ( strchr() is better for single character searches ))
-
- ----------------------------------------
-
- Usage: insert( StrAddr String )
-
-
- Inserts String ( excluding null byte ) starting at
- StrAddr ( address returned by a previous string search function etc. ).
- ( buffer at StrAddr must be large enough to hold the extra bytes )
-
-
-
- ***********
- * Input *
- ***********
-
-
- Usage: [D0 =] gets( Buffer )
-
-
- Reads characters into your Buffer until a newline character is read.
- The newline character isn't stored in Buffer, and the character
- string is NULL terminated. The Buffer address is returned in D0.
- Buffer should not exceed 127 bytes.
-
-
-
-
- *********************************
- * Standard C string functions *
- *********************************
-
-
- Usage: [location =] strcat( StrAddr String )
-
-
- Concatenates character string String to the end of StrAddr,
- placing a null byte at the end of the final string.
- Returns ( original ) address of StrAddr in D0.
-
- ----------------------------------------
-
- Usage: [location =] strchr( StrAddr Char )
-
-
- Searches at StrAddr for the first occurance of character Char.
- If it's found, the address of the character is
- returned in D0, otherwise D0 = 0.
-
- ( be sure the actual character value is loaded into Char, not
- its address ( use: #'x' ))
-
- ----------------------------------------
-
- Usage: [location =] strcpy( StrAddr String )
-
-
- Copies String to StrAddr, returning ( original ) addr of StrAddr
- in D0.
-
- ----------------------------------------
-
- Usage: [length =] strlen( StrAddr )
-
-
- Returns the number of characters at StrAddr, excluding the
- null byte in D0.
-
- ----------------------------------------
-
- Usage: [location =] strncat( StrAddr String Length )
-
-
- Concatenates character string String to the end of StrAddr,
- until either the null byte is reached, or Length bytes have been
- concatenated, whichever occurs first. Returns ( original ) addr
- of StrAddr in D0.
-
- ----------------------------------------
-
- Usage: [location =] strncpy( StrAddr String Length )
-
-
- Copies String to StrAddr until either the null byte is reached,
- or Length bytes have been copied, whichever occurs first.
- Returns ( original ) addr of StrAddr in D0.
-
- ----------------------------------------
-
- Usage: [location =] strrchr( StrAddr Char )
-
-
- Searches at StrAddr for the last occurance of the character Char.
- If found, its address is returned in D0, otherwise D0 = 0.
-
- ( be sure the actual character value is loaded into Char, not
- its address ( use: #'x' ))
-
- ----------------------------------------
-
-
- Enjoy!
-
-